package Demo1;

import jakarta.servlet.ServletException;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;

import java.io.IOException;

public class AServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        User user = new User();
        user.setId("111");
        user.setName("jack");
        req.setAttribute("Userobj",user);
        // 转发机制
//        req.getRequestDispatcher("/b").forward(req,resp);


        // 重定向机制:
        resp.sendRedirect(req.getContextPath()+"/b");

    }

}
